using System;
using System.Collections;
using System.Collections.Generic;

using UnityEngine;

namespace ALPackage
{
    /// <summary>
    /// UI系统层级用于对canvas做动态管理的脚本对象
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class _AALUILayerDynamicNodeMono<T> : _AALUILayerBasicNodeMono<T> where T : _AALUILayerBasicMonoData
    {
        /// <summary>
        /// 检测函数
        /// </summary>
        protected override void _check()
        {
            if(!_m_bNeedCheck || null == this || null == gameObject)
            {
#if UNITY_EDITOR
                if(_m_bNeedCheck)
                    UnityEngine.Debug.LogError("Check mono Enable error!");
#endif
                return;
            }

            _m_bNeedCheck = false;

            //判断状态是否变更，如未变更则不处理
            if(_m_bDealedEnableState == gameObject.activeInHierarchy)
                return;
            //设置新状态
            _m_bDealedEnableState = gameObject.activeInHierarchy;

            if(_m_bDealedEnableState)
            {
                //对象有效，此时进行注册处理
                ALUILayerMgr.instance.addUILayerDynamicNode(node.createUILayerNode(), node.addOrderInLayer);
            }
            else
            {
                //此时执行注销操作
                ALUILayerMgr.instance.rmvLayerNode(node.goInstanceId);
            }
        }


    }
}